import pojo.User;
import service.LoginService;
import service.impl.LoginServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = "/Login")
public class LoginServlet extends HttpServlet {
    protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //设置响应编码格式
        response.setContentType("text/html;charset=utf-8");
        //获取请求信息
        String uname=request.getParameter("uname");
        String pwd=request.getParameter("pwd");
        System.out.println(uname+":"+pwd);
        //处理请求信息
           //获取业务层对象
            LoginService ls= new LoginServiceImpl();
            User u=ls.checkLoginService(uname,pwd);
            System.out.println(u);
        //响应处理结果
        if(u!=null){
            response.getWriter().write("登录成功");
        }else {
            response.getWriter().write("登录失败");
        }
    }


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
